import { 
  Entity, 
  EntityRepository, 
  Repository, 
  Column, 
  PrimaryGeneratedColumn, 
  CreateDateColumn, 
  ManyToOne, 
  JoinColumn } from "typeorm";

@Entity()
export class Message {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  chat_id: number;

	@CreateDateColumn()
  time: Date;
  
  @Column({default: null})
  repeatAt: Date;

  @Column({type: 'text', default: ''})
  prompt: string;

  @Column({default: 0})
  prompt_token: number;

  @Column({type: 'text', default: ''})
  repeat: string;

  @Column({default: 0})
  repeat_token: number;

  @Column({default: null})
  model: string;
}

@Entity()
export class MessageMeta{
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => Message)
  @JoinColumn({ name: 'message_id' })

  @Column({ type: 'varchar', length: 60, unique: true })
  meta_key: string

  @Column({ type: 'text', default: ''})
  meta_value: string;
}


@EntityRepository(Message)
export class MessageRepository extends Repository<Message> {
  
}